//
//  GoodsBottomView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/17.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "GoodsBottomView.h"

@interface GoodsBottomView ()

@end

@implementation GoodsBottomView

-(id)initWithFrame:(CGRect)aFrame inSuperView:(UIView *)aSuperView{
    if (self = [super initWithFrame:aFrame inSuperView:aSuperView]) {
        self.backgroundColor = [UIColor whiteColor];
        NSArray * comiArr = @[@"加入购物车",@"立即购买"];
        for (int i=0; i<2; i++) {
            GLGWButton * comitBut = [[GLGWButton alloc] initWithFrame:CGRectMake(KScreenWidth - kWidthProportion_In_iPhoneTriploid(191) + kWidthProportion_In_iPhoneTriploid(88)*i, kHeightProportion_In_iPhoneTriploid(9), kWidthProportion_In_iPhoneTriploid(88), kHeightProportion_In_iPhoneTriploid(40)) titleLableFont:SYSTEMFONT(12) titleColor:[UIColor whiteColor] inSuperView:self];
            comitBut.tag = 170+i;
            comitBut.title = comiArr[i];
            if (i==0) {
                comitBut.backgroundColor = [UIColor colorWithHexString:@"#A89A60" alpha:0.6];
                UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:comitBut.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(comitBut.frame.size.height/2,comitBut.frame.size.height/2)];//圆角大小
                CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
                maskLayer.frame = comitBut.bounds;
                maskLayer.path = maskPath.CGPath;
                comitBut.layer.mask = maskLayer;
            }else{
                comitBut.backgroundColor = [UIColor colorWithHexString:@"#A89A60"];
                UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:comitBut.bounds byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight) cornerRadii:CGSizeMake(comitBut.frame.size.height/2,comitBut.frame.size.height/2)];//圆角大小
                CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
                maskLayer.frame = comitBut.bounds;
                maskLayer.path = maskPath.CGPath;
                comitBut.layer.mask = maskLayer;
            }
            [comitBut addTarget:self action:@selector(bottomButAction:) forControlEvents:UIControlEventTouchUpInside];
        }
        //
        NSArray * selectTitArr = @[@"店铺",@"联系卖家",@"购物车"];
        NSArray * imageArr = @[@"icon_dianpu_dianji",@"icon_dianhua",@"icon_gouwuche_xuanzhe"];
        CGFloat butWidth = (KScreenWidth - kWidthProportion_In_iPhoneTriploid(191))/3;
        for (int j=0; j<3; j++) {
            GLGWButton * selectBut = [[GLGWButton alloc] initWithFrame:CGRectMake(butWidth*j, 0, butWidth, self.height) titleLableFont:SYSTEMFONT(10) titleColor:[UIColor colorWithHexString:@"#999999"] inSuperView:self];
            selectBut.title = selectTitArr[j];
            selectBut.image_Name = imageArr[j];
            if (j==0) {
                [selectBut setTitleColor:kColor_Rule_Yellow forState:UIControlStateNormal];
            }
            [selectBut setImagePositionWithType:SSImagePositionTypeTop spacing:kHeightProportion_In_iPhoneTriploid(5)];
            selectBut.tag = 172+j;
            [selectBut addTarget:self action:@selector(bottomButAction:) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    return self;
}

-(void)bottomButAction:(GLGWButton *)sender{
    if (self.Block_BottomAction) {
        self.Block_BottomAction(sender);
    }
}

@end
